//
//  FuJinMoreERCollectionViewCell.m
//  GOGOTravel
//
//  Created by dllo on 16/3/6.
//  Copyright © 2016年 果果. All rights reserved.
//

#import "FuJinMoreERCollectionViewCell.h"
#import "fujinMore.h"
#import "FuJinLastPicCollectionViewCell.h"
@interface FuJinMoreERCollectionViewCell ()<UICollectionViewDelegate, UICollectionViewDataSource>

@property (nonatomic, retain) BaseCollectionView *collection;
@property (nonatomic, retain) NSArray *arr;
@end

@implementation FuJinMoreERCollectionViewCell

- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        [self createCollection];
        
    }
    
    return self;
}

- (void)setModel:(fujinMore *)model{
    if (_model != model) {
        [_model release];
        _model = [model retain];
    }
    
   
}


- (void)createCollection{
    
    
    UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
    
    layout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
    layout.minimumInteritemSpacing = 0;
    layout.minimumLineSpacing = 0;
    layout.sectionInset = UIEdgeInsetsMake(0, 0, 0, 0);
    layout.itemSize = CGSizeMake([UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height/2 - 150);
    
    
    
    self.collection = [[BaseCollectionView alloc] initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height/2 - 150) collectionViewLayout:layout];
    _collection.delegate = self;
    _collection.dataSource = self;
    
    _collection.pagingEnabled = YES;
    [self.contentView addSubview:_collection];
    [_collection release];

    [_collection registerClass:[FuJinLastPicCollectionViewCell class] forCellWithReuseIdentifier:@"FuJinLastPicCollectionViewCell"];
    
    
    
}



- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
    return _arr.count;
}

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
    FuJinLastPicCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"FuJinLastPicCollectionViewCell" forIndexPath:indexPath];
    
    NSDictionary *dic = _arr[indexPath.row];
    
    cell.dic = dic;
    
    return cell;
}



- (void)dealloc{
    [_collection release];
    [_arr release];
    [_model release];
    [_model release];
    [super dealloc];
}

@end
